import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDClUO5yJRw4QC3Gyr9YviEte+G\n' +
  '+Y6L3tXk4tRNODIpvYLO6bgvwiIfhqiiWicYRAefV8a+jKWxbZE7Vgu37dNbE/gD\n' +
  '0dxJTE8sx6N42oYz8cuWNpvy7pz/LjoQw4pZAIpY9tk8xiuoOO3X1jRRPx0lrx3u\n' +
  '7KqJuK8yBqXhXw4/hwIDAQAB'

const privateKey = 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMKVQ7nIlHDhALcb\n' +
  'Kv1i+IS174b5jove1eTi1E04Mim9gs7puC/CIh+GqKJaJxhEB59Xxr6MpbFtkTtW\n' +
  'C7ft01sT+APR3ElMTyzHo3jahjPxy5Y2m/LunP8uOhDDilkAilj22TzGK6g47dfW\n' +
  'NFE/HSWvHe7sqom4rzIGpeFfDj+HAgMBAAECgYAnMcvXk1ibOCddusI5EgN/L+qU\n' +
  'pJYbBILPPQWInGY2VC8SIK/yJsea1BQJx+ESGTnz1cl5vnjtuWVEr3tizCwDVW6q\n' +
  '0tV0+dvRkV+hiNUYPwoPcWNplOaKV0PkZg66LzObnkDTPY2qy2LejiknnelrJOyZ\n' +
  'htm5HR1Z+to2UnR+8QJBAO7MuxLuR9Q4m22pX7IQGdkwiOrhDzm3Okl3eZWw1JB0\n' +
  'DAmpMI34lAsN2IJtvfPWNHGmYjhfPD15uuGdiVlWgE8CQQDQmTcRzsSl75mb41pJ\n' +
  '0tXQCHlrZpdLUpNZf46qsipSiXnSoXvupUsx0XRDZQkaHdRHzuJy9ME3/EtpIp4E\n' +
  'JodJAkEArwfYxtNoSqEDK6nNvpIWoB72/FHh+wfV7StpLtLhus+UUzBzqlvdBw0q\n' +
  '+M6/QA5tei/eJjuHx/eFhwEVPyor+QJABSCvDN4DUXzpTr6w+n2XSezbZzt3Xp+i\n' +
  'BaIwFJwalDrS5s2XaU9g4NGgRQPXzG+NR1KbmG3RzhmClQwHzFxSGQJBAKnDv7+l\n' +
  'KS5AzHuCZVjIGKHa0IS3dY/v3bU0Eo3lcV9g/mHxw0l04N6wcis+WXh6qeJrhGTl\n' +
  'f9JobFube8ZsOP8='

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对需要加密的数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey)
  return encryptor.decrypt(txt)
}

